package all.com.jinyongqunxiax.component;

import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import all.com.jinyongqunxiax.R;

public class JxFormItemTextTwoField extends JxForm.AbstractItemViewModel {
    private String title;

    private JxForm.TextField field1;
    private JxForm.TextField field2;


    public JxFormItemTextTwoField(int level, String title,
                                  JxForm.TextField field1, JxForm.TextField field2,
                                  JxForm.OnClickListener removeButtonListener) {
        super(R.layout.jxform_text_item_two_field, level, removeButtonListener);
        this.title = title;

        this.field1 = field1;
        this.field2 = field2;
    }

    @Override
    void bind(View view) {
        TextView textView = view.findViewById(R.id.form_item_title);
        if (textView != null) {
            textView.setText(this.title);
        }

        TextView label1TextView = view.findViewById(R.id.form_item_filed1_label);
        if (label1TextView != null) {
            label1TextView.setText(this.field1.label);
        }
        EditText label1EditText = view.findViewById(R.id.form_item_filed1_value);
        if (label1EditText != null) {
            label1EditText.setHint(this.field1.hint);
            label1EditText.setText(this.field1.value);
        }

        TextView label2TextView = view.findViewById(R.id.form_item_filed2_label);
        if (label2TextView != null) {
            label2TextView.setText(this.field2.label);
        }
        EditText label2EditText = view.findViewById(R.id.form_item_filed2_value);
        if (label2EditText != null) {
            label2EditText.setHint(this.field2.hint);
            label2EditText.setText(this.field2.value);
        }
    }

    @Override
    int removeButtonID() {
        return R.id.form_item_delete;
    }
    @Override
    int intentViewID() {
        return R.id.form_header_guide_line;
    }
}
